//当前模块：API进行统一管理
import requests from "./request.js";
import mockRequests from "./mockRequest.js"

//   三级联动接口
//  /api/product/getBaseCategoryList   get请求  无参数

export const reqCategoryList = ()=>{
    //发请求  axios发请求返回结果Promise对象
    return requests({url:'/product/getBaseCategoryList',method:'get'})
    
}

//获取banner（Home首页大轮播图）
export const reqGetBannerList = ()=>mockRequests({ url: '/banner', method: 'get' });

//获取floor数据
export const reqFloorList = ()=>mockRequests.get('/floor');

//获取搜索模块的数据  地址  /api/list  post
export const reqGetSearchInfo = (params)=>{
  return requests ({url:'/list',method:'post',data:params})
}

//获取详情页面的数据 地址  /api/item/{ skuId }   get
export const reqGoodsInfo = (skuId)=>{
  return requests ({url:`/item/${skuId}`,method:'get',data:skuId})
}

//将产品添加到购物车当中（获取更新的个数，商品名称）  地址  /api/cart/addToCart/{ skuId }/{ skuNum }  post
export const reqAddOrUpdateShopCart = (skuId,skuNum)=>{
  return requests ({url:`/cart/addToCart/${ skuId }/${ skuNum }`,method:'post'})
}

//获取购物车列表数据接口  地址 /api/cart/cartList  get
export const reqCartList = () =>{
  return requests ({url:`/cart/cartList`,method:'get'})
}

//删除购物产品的接口  地址:/api/cart/deleteCart/{skuId}  DELETE
export const reqDeleteCartById = (skuId)=>{
  return requests ({url:`/cart/deleteCart/${skuId}`,method:'delete'})
}

//修改商品的选中状态  地址：/api/cart/checkCart/{skuId}/{isChecked}   get
export const reqUpdateCheckedByid= (skuId,isChecked)=>{
  return requests ({url:`/cart/checkCart/${skuId}/${isChecked}`,method:'get'})
}

//获取验证码  地址:/api/user/passport/sendCode/{phone}  get
export const reqGetCode= (phone) =>{
  return requests({url:`user/passport/sendCode/${phone}`,method:'get'})
}

//注册   地址：/api/user/passport/register   post    phone,password,code
export const reqUserRegister = (data)=>{
  return requests({url:`/user/passport/register`,data,method:'post'})
}

//登录   地址：/api/user/passport/login    post   phone,password
export const reqUserLogin = (data)=>{
  return requests({url:`/user/passport/login`,data,method:'post'})
}

//获取用户信息(需要带用户的token)     地址：/api/user/passport/auth/getUserInfo  get
export const reqUserInfo = ()=>{
  return requests({url:`/user/passport/auth/getUserInfo`,method:'get'})
}

//退出登录  地址：/api/user/passport/logout  get
export const reqLogout = () =>{
  return requests({url:`/user/passport/logout`,method:'get'})
}

//获取用户地址信息  地址:/api/user/userAddress/auth/findUserAddressList    get
export const reqAddressInfo = () =>{
  return requests({url:`/user/userAddress/auth/findUserAddressList`,method:'get'})
}

//获取商品清单 地址：/api/order/auth/trade   get
export const reqOrderInfo = () =>{
  return requests({url:'/order/auth/trade',method:'get'})
}

//获取addressinfo数据
export const reqadressinfo = ()=>mockRequests.get('/addressinfo');

//提交订单的接口  地址：/api/order/auth/submitOrder?tradeNo={tradeNo}   post
export const reqSubmitOrder = (tradeNo,data) =>{
  return requests({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,data,method:'post'})
}

//获取支付信息  地址：/api/payment/weixin/createNative/{orderId}  get
export const reqPayInfo = (orderId) =>{
  return requests({url:`/payment/weixin/createNative/${orderId}`,method:'get'})
}

//获取支付订单状态  地址:/api/payment/weixin/queryPayStatus/{orderId}   get
export const reqPayStatus = (orderId) =>{
  return requests({url:`/payment/weixin/queryPayStatus/${orderId}`,method:'get'})
}

//获取我的订单列表  地址：/api/order/auth/{page}/{limit}   get
export const reqMyOrderList = (page,limit) =>{
  return requests({url:`/order/auth/${page}/${limit}`,method:'get'})
}